|
|
@@ -4,21 +4,17 @@ module Agents
|
4
|
4
|
class PublicTransportAgent < Agent
|
5
|
5
|
cannot_receive_events!
|
6
|
6
|
description <<-MD
|
7
|
|
- The Public Transport Agent monitors if any bus is expected to arrive at a particular stop in 5 minutes or less.
|
8
|
|
- You must specify 5 things for it too work correctly. Your state, city, route, stop and destination. All these things
|
9
|
|
- should be in the language that nextbus understands. For details check out http://www.nextbus.com/predictor/stopSelector.jsp?a=sf-muni and http://www.apihub.com/nextbus/api/nextbus-api/docs/reference.
|
10
|
|
-
|
11
|
7
|
Specify the following user settings:
|
12
|
8
|
- stops (array)
|
13
|
9
|
- agency (string)
|
14
|
10
|
- alert_window_in_minutes (integer)
|
15
|
11
|
|
16
|
|
- This Agent generates Events based on NextBus GPS transit predictions. First, select an agency by visiting http://www.nextbus.com/predictor/agencySelector.jsp and finding your transit system. Once you find it, copy the part of the URL after `?a=`. For example, for the San Francisco MUNI system, you would end up on http://www.nextbus.com/predictor/stopSelector.jsp?a=sf-muni and copy "sf-muni". Put that into this Agent's agency setting.
|
|
12
|
+ This Agent generates Events based on NextBus GPS transit predictions. First, select an agency by visiting http://www.nextbus.com/predictor/agencySelector.jsp and finding your transit system. Once you find it, copy the part of the URL after `?a=`. For example, for the San Francisco MUNI system, you would end up on http://www.nextbus.com/predictor/stopSelector.jsp?a=sf-muni and copy "sf-muni". Put that into this Agent's agency setting.
|
17
|
13
|
|
18
|
14
|
Next, find the stop tags that you care about. To find the tags for the sf-muni system, for the N route, visit this URL:
|
19
|
15
|
http://webservices.nextbus.com/service/publicXMLFeed?command=routeConfig&a=sf-muni&r=N
|
20
|
16
|
|
21
|
|
- The tags are listed as tag="1234". Copy that number and add the route before it, separated by a pipe (|) symbol. Once you have one or more tags from that page, add them to this Agent's stop list. E.g,
|
|
17
|
+ The tags are listed as tag="1234". Copy that number and add the route before it, separated by a pipe '|' symbol. Once you have one or more tags from that page, add them to this Agent's stop list. E.g,
|
22
|
18
|
|
23
|
19
|
agency: "sf-muni"
|
24
|
20
|
stops: ["N|5221", "N|5215"]
|
|
|
@@ -31,12 +27,7 @@ module Agents
|
31
|
27
|
|
32
|
28
|
alert_window_in_minutes: 5
|
33
|
29
|
|
34
|
|
-having the agent's default check period be every minute, and creating an Event in #check whenever a new tripTag (supplied by the predictionsForMultiStops API) shows up within alert_window_in_minutes from the stop. Do not create events for the same tripTag more than once per stop. I'd do this by keeping a list of [stop tag, tripTag, timestamp] tuples in memory and checking to make sure one doesn't already exist before making a new Event. This memory should get cleaned up when timestamp is older than an hour (or something) so that it doesn't fill up all of the Agent's memory.
|
35
|
|
-
|
36
|
|
-The NextBusAgent doesn't need to receive Events.
|
37
|
|
-
|
38
|
|
-It needs to fetch XML from one URL, store a list of timestamps in memory, and make Events.
|
39
|
|
-
|
|
30
|
+ This memory should get cleaned up when timestamp is older than an hour (or something) so that it doesn't fill up all of the Agent's memory.
|
40
|
31
|
MD
|
41
|
32
|
|
42
|
33
|
|